<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@include file="/taglibs.jsp" %>
<!doctype html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <link href="${ctx}/resources/semanticui/semantic.min.css" rel="stylesheet" type="text/css"/>
    <link href="${ctx}/resources/apps.css" rel="stylesheet" type="text/css"/>
    <title>候选人简历</title>
</head>
<style>
    img {
        width: 100%;
    }

    body {
        background-color: #F8F8F8;
    }

	.ui.segment {
		background-color: #F8F8F8;
	}
	.container{
		position: relative;
		top: -2rem;
		background-color: #F8F8F8;
		margin-left: auto;
		margin-right: auto;
		width: 84%;
		text-align: left;
		border: none;
		border-radius: 5px;

	}

	.person_info{
		padding: 10px 5px 0 5px;
		font-weight: bold;
		font-size: 15px;
		line-height: 25px;
		background-color: white;
		color: #275eac;
		border-radius:5px;

	}
	.recom{
		font-weight: bold;
		font-size: 15px;
		line-height: 25px;
		color: #197EC6;
	}
	.box{
		background-color: white;
		padding: 0 5px 0 5px
	}
	.divider{

		border-bottom: solid 1px #CCCCCC;
		line-height: 35px;
	}
	.feedBack{
		margin-top: 2em;
		margin-left: 2%;
		margin-right: 2%;

	}
	.resume_file{
		overflow:hidden;
		text-overflow:ellipsis;
		white-space:nowrap;
		display: inline;
	}


	.left{
		width:20px;
		height:10px;
		float: left;
		font-style:normal;
	}
	.left img{
		max-width:100%;
		min-height:100%;
		margin-bottom:-3px
	}
	.right{
		width:180px;
		height:100%;
		float: right; /* bfc模块触发 */
		display: inline;
		verflow:hidden;
		text-overflow:ellipsis;
		white-space:nowrap
	}
	.middle{
		width: auto;
		height: 100%;
		overflow:hidden;  /* bfc模块触发，如过取消将出现文字环绕效果 */
		display: inline;
		padding: 0 8px;
		verflow:hidden;
		text-overflow:ellipsis;
		white-space:nowrap
	}
	.recom_info{
		margin: 18px 0 3px 0;
		padding: 5px;
		background: white;
		border: 0px solid;
		border-radius: 5px;
	}
</style>
<body>
<div>
    <img src="${ctx}/resources/images/trend.jpg">
</div>
<div class="container">
    <div class="person_info">
        基本信息
    </div>
        <input type="hidden" name="jobId" id="jobId" value="${jobId}"/>
        <input type="hidden" name="recommendId" id="recommendId" value="${recommendId}">
        <input type="hidden" name="empId" id="empId" value="${employee.id}"/>

        <div class="box">
            <div class="divider">
				<div class="left"><img src="${ctx}/resources/images/icons/candidate.png"></div>
				<div class="right"> <c:choose>
					<c:when test="${(recom.reason).indexOf('自荐')==-1}">
						${employee.name}
					</c:when>
					<c:when test="${status==5||status==6}">
						<span class="hideName"> ${employee.name}</span>
					</c:when>
					<%--					<c:when test="${recom == null}">--%>
					<%--						<span > ${employee.name}</span>--%>
					<%--					</c:when>--%>
					<c:otherwise>
						<span class="hideName"> ${employee.name} </span>

					</c:otherwise>
				</c:choose></div>
				<div class="middle">姓&nbsp;&nbsp;名：</div>

            </div>
            <div class="divider">
				<div class="left"><img src="${ctx}/resources/images/icons/1.jpg"></div>
				<div class="right">${employee.companyName}</div>
				<div class="middle">现任公司：</div>
            </div>
            <div class="divider">
				<div class="left"><img src="${ctx}/resources/images/icons/2.jpg" style="margin-bottom:-3px"></div>
				<div class="right"><c:choose>
					<c:when test="${not empty employee.roleName}">
						${employee.roleName}
					</c:when>
					<c:otherwise>
						${roleName}
					</c:otherwise>
				</c:choose></div>
				<div class="middle">现任职位：</div>

            </div>

            <div class="divider">
				<div class="left"><img src="${ctx}/resources/images/icons/3.jpg"></div>
				<div class="right">
					<c:choose>
						<c:when test="${not empty employee.cityName}">
							${employee.cityName}
						</c:when>
						<c:otherwise>
							${cityName}
						</c:otherwise>
					</c:choose>
				</div>
				<div class="middle">所在城市：</div>

            </div>
            <div class="divider">
				<div class="left"><img src="${ctx}/resources/images/icons/4.jpg" ></div>
				<div class="right">${employee.bestdomain}</div>
				<div class="middle">负责区域：</div>

            </div>

            <div class="divider">
				<div class="left"><img src="${ctx}/resources/images/icons/5.jpg"></div>
				<div class="right">${employee.workage}年</div>
				<div class="middle">工作年限：</div>
            </div>


<%--            <div class="divider">--%>
<%--				<div class="left"><img src="${ctx}/resources/images/icons/6.jpg" style="margin-bottom:-3px"></div>--%>
<%--				<div class="right">${employee.expectJobName}</div>--%>
<%--				<div class="middle">期望职位：</div>--%>

<%--            </div>--%>
            <div style="line-height: 35px">
				<div class="left"><img src="${ctx}/resources/images/icons/6.jpg" style="margin-bottom:-3px"></div>
				<div class="right">${employee.expectJobName}</div>
				<div class="middle">期望职位：</div>



            </div>

        </div>

        <c:choose>
            <c:when test="${(recom.reason).indexOf('自荐')==-1}">
                <div class="ui segment" id="cont-next">
                    <div class="fluid ui button" id="next">邀请面试</div>
                </div>
            </c:when>
            <c:when test="${status==6}">

            </c:when>
            <c:otherwise>
				<div class="ui segment" id="cont-next">
					<div class="fluid ui button send" style="margin: 180px 0 0 0; padding-top: 1.0rem;padding-bottom: 1.0rem;float:left; display:inline;background-color: #01b3d1;border-radius: 5px" id="confirm">发送职位沟通邀请</div>

				</div>


<%--                <div class="ui segment sendBackgroud" id="cont-next">--%>
<%--                    <div class="fluid ui button" id="confirm"--%>
<%--                         style="margin-right: 2%;margin-left: 2%;width: 90%;position: fixed;bottom: 1em;">发送职位沟通邀请--%>
<%--                    </div>--%>
<%--                </div>--%>
            </c:otherwise>
        </c:choose>
    </div>

</div>

<script src="${ctx}/resources/jweixin-1.0.0.js"></script>

<script src="${ctx}/resources/semanticui/jquery-2.1.4.min.js"></script>
<script src="${ctx}/resources/semanticui/semantic.js" type="text/javascript"></script>
<script type="text/javascript">

    var handler = {
        activate: function () {
            $(this).addClass('active').siblings().removeClass('active');
            //邀请面试
            if ($(this).attr('id') == 'next') {

                var postUrl = '${ctx}/wechat/headhunter/recommend/recommendInterview.do';

                var param = {};
                param['jobId'] = $('#jobId').val();
                param['empId'] = $('#empId').val();

                $.ajax({
                    url: postUrl,
                    type: "POST",
                    data: param,
                    success: function (data) {
                        if (data.errorcode == 0) {
                            var recommendId = data.recommendId;
                            location.href = "${ctx}/wechat/hunter/hr/toInterview.do?recommendid=" + recommendId;
                        }
                        // alert(""+data.msg)
                    },
                    error: function () {
                        alert("服务出错，请稍后尝试");
                    }
                });
            }

            //面试前沟通确认
            if ($(this).attr('id') == 'confirm') {
                var jobId = $('#jobId').val();
                var empId = $('#empId').val();
                var recommendId = $('#recommendId').val();
                var getUrl = '${ctx}/wechat/hunter/hr/updateRecomStatus.do?jobId=' + jobId + '&recommendId=' + recommendId + '&empId=' + empId + '&status=' + 6;
                $.ajax({
                    url: getUrl,
                    type: "GET",
                    success: function (data, status) {
                        if (data.errorcode == 1) {
                            alert("已发送沟通邀请，等待候选人回复！")
                            // wx.back();
                            <%--location.href = "${ctx}/wechat/hunter/hr/jobcandidatelist.page";--%>
                            var getUrl = '${ctx}/wechat/hunter/hr/toJobView.do?jobid=' + jobId;
                            location.href = getUrl;
                        } else {
                            alert(data.msg);
                        }

                    },
                    error: function () {
                        alert("服务出错，请稍后尝试");
                    }
                });
            }

            //有意向并关注
            if ($(this).attr('id') == 'intention') {
                var jobId = $('#jobId').val();
                var empId = $('#empId').val();
                var recommendId = $('#recommendId').val();
                var getUrl = '${ctx}/wechat/hunter/hr/updateRecomStatus.do?jobId=' + jobId + '&recommendId=' + recommendId + '&empId=' + empId + '&status=' + 5;
                $.ajax({
                    url: getUrl,
                    type: "GET",
                    success: function (data, status) {
                        if (data.errorcode == 1) {
                            //alert("有意向并关注"+data.msg)
                            location.href = "${ctx}/wechat/hunter/hr/jobcandidatelist.page";
                        }

                    },
                    error: function () {
                        alert("服务出错，请稍后尝试");
                    }
                });
            }

            //拒绝
            if ($(this).attr('id') == 'reject') {
                var jobId = $('#jobId').val();
                var empId = $('#empId').val();
                var recommendId = $('#recommendId').val();
                var getUrl = '${ctx}/wechat/hunter/hr/updateRecomStatus.do?jobId=' + jobId + '&recommendId=' + recommendId + '&empId=' + empId + '&status=' + 3;
                $.ajax({
                    url: getUrl,
                    type: "GET",
                    success: function (data, status) {
                        if (data.errorcode == 1) {
                            // alert("拒绝"+data.msg)
                            alert("操作成功！")
                            wx.closeWindow();
                            <%--  location.href = "${ctx}/wechat/hunter/hr/jobcandidatelist.page";--%>
                        }

                    },
                    error: function () {
                        alert("服务出错，请稍后尝试");
                    }
                });
            }
        }
    };


    $(document).ready(function () {
        $('.button').on('click', handler.activate);

        wx.ready(function () {
            wx.hideOptionMenu();
        });

        //20191128 add by 李想  由原姓名展示变更为隐藏名 李尚良提出，详见20191125excel开发进度表
        var hideSpan = document.querySelectorAll(".hideName");
        hideSpan.forEach(function (i, j) {
            console.log(i);
            i.innerHTML = hidden(i.innerHTML, 1, 0);
        })
        hideSpan.innerHTML = hidden(hideSpan.innerHTML, 1, 0);
    });

    function hidden(str, frontLen, endLen) {
        var len = str.length - frontLen - endLen;

        var xing = '';
        for (var i = 0; i < len; i++) {
            xing += '*';
        }
        return str.substring(0, frontLen) + xing + str.substring(str.length - endLen);
    }

</script>
</body>
</html>